package basicConcepts;

import java.util.ArrayList;


public class GenericMethod {

	public <T> void doSomeThing(T t){
		
	}
	
	
	
	// Diff between Method 1 and Method 2
	public < T extends Exception> void Method1(ArrayList<T> t){
		//it can take an ArrayList which is created using eny thing of type Exception 
	}
	
	public  void Method2(ArrayList<Exception> t){
		//it can take an ArrayList which is created using only of type Exception
	}
	
	// Diff between Method 1 and Method 2 END
	
	
	/**
	 * this method can take an Array list which contains objects belonging to any class in java
	 * @param l
	 */
	public void Method3(ArrayList<?> l){
		
	}
	
	/**
	 * 
	 * The below two methods shows the diff between "? extends Number" and <T extends Number>
	 * 
	 */
	static void gPrint(ArrayList<? extends Number> l) {
	    for(Number n : l) {
	        System.out.println(n);
	    }
	}

	static <T extends Number> void gPrintA(ArrayList<T> l) {
	    for(Number n: l) {
	        System.out.println(n);
	    }
	}
	
	/**
	 * For the above two methods
	 http://stackoverflow.com/questions/11497020/java-generics-wildcard-extends-number-vs-t-extends-number
	 There is no difference in this case, because T is never used again.
	 The reason for declaring a T is so that you can refer to it again, thus binding two parameter types, or a return type together.
	 **/
	
	
}
